<?php if($products && $status==1) { ?>
<div class="boss-bought-together">
<div class="box">
    <div class="box-heading"><?php echo $heading_title; ?></div>
    <div class="box-content">
            <div id="product-image">
                <ul id="bought_together_image">
					<li><a title="<?php echo $name; ?>" href="<?php echo $href; ?>"><img src="<?php echo $thumb; ?>" alt="<?php echo $name; ?>" /></a></li>
                    <?php foreach ($products as $product) { ?>
                        <?php if ($product['thumb']) { ?>
                            <li><a title="<?php echo $product['name']; ?>" href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></li>
                        <?php } ?>
                    <?php } ?>
                </ul>
                <div id="price-cart"> 
                    <div class="price-all">
                        <strong><?php echo $text_all_select; ?></strong><span id="total"><?php echo $total; ?></span>
                    </div>
                    <div class="cart">
                        <input type="button" value="<?php echo $button_cart; ?>" onclick="addAllToCart();" class="button" />
                    </div>
                </div>
            </div>
            <form id="bought_together_form">
			<p>
				<input type="checkbox" checked="checked" name="bought_together_item" value="<?php echo $price.'_'.$product_id; ?>" />
				<?php echo $text_item; ?>
				<a title="<?php echo $name; ?>" href="<?php echo $href; ?>" class="active"><?php echo $name.':'.$price; ?></a>
			</p>
                <?php foreach ($products as $product) { ?>
				<p>
					<?php if ($product['thumb']) { ?>
						<input type="checkbox" checked="checked" name="bought_together_item" value="<?php echo $product['price'].'_'.$product['product_id']; ?>" />
						<a title="<?php echo $product['name']; ?>" href="<?php echo $product['href']; ?>" class="active"><?php echo $product['name'].':'.$product['price']; ?></a>
                            
					<?php }?>
				</p>
                <?php  } ?>
            </form>
    </div>
</div>

<script type="text/javascript"><!--

$('input[name="bought_together_item"]').change(function() {	
	var $price_total = 0;
	var $i = 0;
	var $j = 0;
	var vt = '';

	$("input:checked").each(function(){
	
		var str = $(this).val();
		var v = str.indexOf("_");
		var price_format = str.substr(0,v);
		var symbol = price_format.replace(/[0-9]*[.,]*[0-9]*/gi, '');
		var price  = price_format.replace(symbol, ''); 
        var price = price.replace(",",'');
		vt = price_format.indexOf(symbol);     
		$price_total = eval($price_total) + eval(price);
		$price_total = eval($price_total).toFixed(2);
		
		
		$(this).next('a').removeClass().addClass('active');     
		$i = $('input[name="bought_together_item"]').index(this); 								
		$(" #bought_together_image li:eq("+$i+") ").show(1000);					
		
		if (vt > 0) {
			$('#total').html($price_total + symbol)
		}else {
			$('#total').html(symbol + $price_total)
		}	
	});	
		
	
	$("input:not(:checked)").each(function(){
		$j = $('input[name="bought_together_item"]').index(this); 						  	
		if($j>=0)
		{
			$(this).next('a').removeClass();
			$("ul#bought_together_image li:eq("+$j+")").hide(1000);
			
			if($price_total==0)
			{
				$("#price-cart").hide(); 	
			}else{
				$("#price-cart").show(); 
			}
		}
	});
	
	
});
//--></script> 
</div>
<script type="text/javascript"><!--
    $(document).ready(function() {
        $('.product-info').after('<div id="boss-bought-together"></div>');
    });
//--></script> 
<script type="text/javascript"><!--
$(document).ready(function() {
	if (jQuery(".boss-bought-together").html()) {
		jQuery("#boss-bought-together").html(jQuery(".boss-bought-together").html());
		jQuery(".boss-bought-together").remove();
	}
});
//--></script>
<?php } ?>